#include <bits/stdc++.h>
// 2025/02/04
// tag: 
// Author: Zhang Muen
using namespace std;

struct {
    int time, x, y;
} mouse[10001];

int n, m, dp[10001][2];

inline bool check(int i, int j){
    return (abs(mouse[i].x - mouse[j].x) + abs(mouse[i].y - mouse[j].y)) <= (mouse[j].time - mouse[i].time);
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= m; i++)
        cin >> mouse[i].time >> mouse[i].x >> mouse[i].y;
    for (int i = 1; i <= m; i++){
        dp[i][0] = max(dp[i - 1][0], dp[i - 1][1]), dp[i][1] = 1;
        for (int j = i - 1; j >= 1; j--){
            if (check(j, i))
                dp[i][1] = max(dp[i][1], dp[j][1] + 1);
        }
    }
    cout << max(dp[m][0], dp[m][1]) << endl;
    return 0;
}